﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace csharpcore7_ch14_ConcurrencyAndAsynchrony
{
    class chapt14_2_6PassParametersToTheThread
    {
        static void _Main()
        {

            Thread t = new Thread(() => Print("Hello From t!"));
            t.Start();


            //使用Lambda表达式，向方法传递任意数量的参数。可以将整个实例过程封装在一个多语句的Lambda表达式中
            new Thread(() =>
            {
                Console.WriteLine("I'm running on another thread!");
                Console.WriteLine("This is so easy!");
            }).Start();



            
        }
        static void Print(string message) { Console.WriteLine(message); }


        static void __Main()
        {
            Thread t = new Thread(Print);
            t.Start("Hello form t !");
            
        }

        static void Print(object messageObj)
        {
            string message = (string)messageObj;
            Console.WriteLine(message);
        }


        static void ___Main()
        {
            //循环启动10个线程
            for (int i = 0; i < 10; i++)
                new Thread(()=> Console.Write(i)).Start();
          
            for (int i = 0; i < 10; i++)
            {
                int temp = i;
                new Thread(() => Console.Write(temp)).Start();
            }
               
        }
    }
}
